<template>
	<view>
		<ikz-loading :css-data="loading_css"></ikz-loading>
		<ikz-topmenu :show-data="topmenu_data" :dataIndex="currentTab" @returnIndex="returnIndex"></ikz-topmenu>
		<view class="">
			<swiper :indicator-dots="indicatorDots" :current="currentTab" :autoplay="autoplay" :interval="interval"
				:duration="duration" @change="changeCurrentTab" :style="'height:'+winHeight+'px'">
				<block v-for="(item,index) in topmenu_data.list" :key="index">
					<swiper-item>
						<scroll-view scroll-y class="ikz-scoll-y">
							<block v-for="(it,idx) in item.address" :key="idx">
								<view class="ikz-list-item" hover-class="ikz-cell-active" hover-stay-time="100"
									@click="returnBack(item.name,it.name)">
									{{ it.name }}
								</view>
							</block>
						</scroll-view>
					</swiper-item>
				</block>
			</swiper>
		</view>
	</view>
</template>

<script>
	var app = getApp( );
	import ikz from '@/pages/Common/tools';
	import ikzTopmenu from '@/pages/Component/Public/Topmenu/index.vue';
	import ikzLoading from '@/pages/Component/Public/Loading/loading.vue';
	var app = getApp( );
	export default {
		components: {
			ikzTopmenu,
			ikzLoading
		},
		data( ) {
			return {
				background: [ 'demo-text-1', 'demo-text-2', 'demo-text-3' ],
				indicatorDots: false,
				vertical: false,
				autoplay: false,
				interval: 2000,
				duration: 500,
				loading_css: {
					display: 'flex'
				},
				topmenu_data: {
					list: [ ]
				},
				winHeight: 0,
				currentTab: 0
			};
		},

		onLoad: function( options ) {},
		onShow: function( ) {
			this.addressInfo( ( res ) => {
				this.loading_css.display = 'none';
			} );
		},
		mounted( ) {
			var that = this;
			uni.getSystemInfo( {
				success: function( res ) {
					let calc = res.windowHeight;
					that.winHeight = calc
				}
			} );
		},
		methods: {
			addressInfo( fn ) {
				var path = "/xyb/agent_address/index";
				var data = {}
				ikz.post( path, data, ( res ) => {
					if ( res.data.code ) {
						this.topmenu_data.list = res.data.data;
						this.$forceUpdate( );
					} else {
						uni.showModal( {
							title: '提示',
							content: '服务器繁忙，请稍后再试',
							showCancel: false,
							success: function( res ) {}
						} );
					}
					fn( );
				} );
			},
			returnBack( title, detail ) {
				app.globalData.campus_data = title + '-' + detail;
				wx.navigateBack( {
					delta: 1
				} )
			},
			returnIndex( e ) {
				this.currentTab = e;
			},
			changeCurrentTab( e ) {
				this.currentTab = e.detail.current;
				console.log( e )
			},
			geselectAddress( ) {
				uni.navigateTo( {
					url: '/pages/Component/Module/Address/Program/saveAddress/index'
				} )
			},

		},
	};
</script>

<style>
	page {
		background: #f2f2f2;
	}

	.ikz-scoll-y {
		box-sizing: border-box;
		padding-top: 100rpx;
		width: 100%;
		height: 100%;
	}

	.swiper-item {

		height: 100px;
	}

	.ikz-list-item {
		box-sizing: border-box;
		padding-left: 20rpx;
		position: relative;
		background: #fff;
		line-height: 80rpx;
	}

	.ikz-list-item:before {
		content: " ";
		position: absolute;
		top: 0;
		right: 0;
		height: 1px;
		border-top: 1rpx solid #d9d9d9;
		color: #d9d9d9;
		left: 20rpx;
	}

	.ikz-list-item:first-child:before {
		display: none;
	}

	.ikz-cell-active {
		opacity: 0.5;
	}
</style>